package com.my.control.validate
{
	import com.my.commons.constants.ConstVars;
	import com.my.view.right.LoginView;
	
	import mx.core.UIComponent;
	
	public class LoginViewValidate extends AbstractValidate implements IValidate
	{
		public function LoginViewValidate(value:UIComponent)
		{
			super(value);
		}
		
		public override function validate():Boolean{
			return usernameValidate() && passwordValidate();
		}
		
		private function usernameValidate():Boolean{
			if(getView().username.text.match(ConstVars.NAME_REGEX)){
				getView().usernameTip.text = "";
				return true;
			}else{
				getView().usernameTip.text = ConstVars.NAME_TIP;
				return false;
			}
		}
		private function passwordValidate():Boolean{
			if(getView().password.text.match(ConstVars.PASS_REGEX)){
				getView().passwordTip.text = "";
				return true;
			}else{
				getView().passwordTip.text = ConstVars.PASS_TIP;
				return false;
			}
		}
		
		
		
		public function getView():LoginView{
			return LoginView(view);
		}
	}
}